home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / TexturingAndModeling:AProceduralApproach / DPShaders / DPMetallic.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  961 b   |  31 lines

  1. #define BROWN     color (0.1307,0.0609,0.0355)
  2. #define BLUE0     color (0.4274,0.5880,0.9347)
  3. #define BLUE1     color (0.1221,0.3794,0.9347)
  4. #define BLUE2     color (0.1090,0.3386,0.8342)
  5. #define BLUE3     color (0.0643,0.2571,0.6734)
  6. #define BLUE4     color (0.0513,0.2053,0.5377)
  7. #define BLUE5     color (0.0326,0.1591,0.4322)
  8. #define BLACK     color (0,0,0)
  9.  
  10. surface
  11. DPMetallic()
  12. {
  13.     point Nf = normalize(faceforward(N, I));
  14.     point V = normalize(-I);
  15.     point R;        /* reflection direction */
  16.     point Rworld;   /* R in world space */
  17.     color Ct;
  18.     float altitude;
  19.  
  20.     R = 2 * Nf * (Nf . V) - V;
  21.     /* Rworld = normalize(vtransform("world", R));*/
  22.     Rworld = normalize(transform("world", R + point "world" (0,0,0)));
  23.     altitude = 0.5 * zcomp(Rworld) + 0.5;
  24.     Ct = spline(altitude,
  25.         BROWN, BROWN, BROWN, BROWN, BROWN,
  26.         BROWN, BLUE0, BLUE1, BLUE2, BLUE3,
  27.         BLUE4, BLUE5, BLACK);
  28.     Oi = Os;
  29.     Ci = Os * Cs * Ct;
  30. }
  31.